package sch.jl.caigou.impl;

import java.util.ArrayList;
import java.util.List;

import jiliang.purchase.demo.BusinessProcessing;
import sch.jl.caigou.dao.TiXingDao;
import sch.jl.caigou.utils.getMax;


public class TiXingImpl extends DaoImpl<Long> implements TiXingDao
{

	@Override
	public long getNumber(String js_id,String name) {
		
		String sql = "";
		if(js_id.contains(",20,"))
		{
			sql = "select count(*) from think_shenqing,think_shengqinglc,think_shenqingbz,think_shenqingxm " +
					"where think_shenqing.lc_id = think_shengqinglc.lc_id and think_shenqing.xm_id='4' and think_shenqingbz.bz_id = think_shengqinglc.bz_id and think_shenqingxm.xm_id = think_shenqing.xm_id and states!='6' and states!='7' and states!='8'";
			//System.out.println(sql);
		}
		else if(js_id.contains(",8,"))
		{
			sql = "select count(*) from think_shenqing,think_shengqinglc,think_shenqingbz,think_shenqingxm,think_lingxing_sbjj " +
					"where think_shenqing.lc_id = think_shengqinglc.lc_id and think_shenqing.xm_id='4' and last_lc = '申请人提交申请' and think_shenqingbz.bz_id = think_shengqinglc.bz_id and think_shenqingxm.xm_id = think_shenqing.xm_id and think_shenqing.bh = think_lingxing_sbjj.bh and think_lingxing_sbjj.fuzerenxm = '"+name+"' and think_shenqing.states='1' ";
		//	System.out.println(sql);
		}
		else if(js_id.contains(",3,"))
		{
			sql = "select count(*) from think_shenqing,think_shengqinglc,think_shenqingbz,think_shenqingxm " +
			"where think_shenqing.lc_id = think_shengqinglc.lc_id and think_shenqing.xm_id='4' and last_lc = '经费负责人审核通过' and think_shenqingbz.bz_id = think_shengqinglc.bz_id and think_shenqingxm.xm_id = think_shenqing.xm_id ";
			//System.out.println(sql);

		}
		else if(js_id.equals(",10,"))
		{
			sql = "select count(*) from think_shenqing,think_shengqinglc,think_shenqingbz,think_shenqingxm " +
			"where think_shenqing.lc_id = think_shengqinglc.lc_id and think_shenqing.xm_id='4' and last_lc = '实验处审核通过' and think_shenqingbz.bz_id = think_shengqinglc.bz_id and think_shenqingxm.xm_id = think_shenqing.xm_id";
			//System.out.println(sql);
		}
		else if(js_id.equals(",15,"))
		{
			sql = "select count(*) from think_shenqing,think_shengqinglc,think_shenqingbz,think_shenqingxm " +
			"where think_shenqing.lc_id = think_shengqinglc.lc_id and think_shenqing.xm_id='4' and last_lc = '采购中心审核通过' and think_shenqingbz.bz_id = think_shengqinglc.bz_id and think_shenqingxm.xm_id = think_shenqing.xm_id";
			//System.out.println(sql);
		}
		else if(js_id.contains(",1,"))
		{
			return 0;
		}
		else
		{
			return 0;
		}
		//System.out.println(sql);
		return getSingleVal(sql);
	}
	
	public long getNumber2(String name)
	{	
		getMax g  = new getMax();
		
		try{
			String sqs = g.getShenhe(name);
					
			String sql = "select count(*) from think_shenqing,think_shengqinglc,think_shenqingbz,think_shenqingxm,think_lingxing_sbjj " +
			"where think_shenqing.lc_id = think_shengqinglc.lc_id and think_shenqing.xm_id='4' and think_shenqingbz.bz_id = think_shengqinglc.bz_id and think_shenqingxm.xm_id = think_shenqing.xm_id and think_shenqing.bh = think_lingxing_sbjj.bh  and think_shenqing.sq_id in ("+sqs+")";
			
			return getSingleVal(sql);
		}catch(Exception ex)
		{
			ex.printStackTrace();
		}
		
		return 0;

	}
	
	public long getNumber3(String js_id,String name)
	{
		
		String sql = "select count(*) from think_shenqing,think_shengqinglc,think_shenqingbz,think_shenqingxm,think_lingxing_sbjj,think_allcateshenqing " +
		"where think_shenqing.lc_id = think_shengqinglc.lc_id and think_shenqing.xm_id='4' and last_lc = '计财处审核通过'  and think_shenqingbz.bz_id = think_shengqinglc.bz_id and think_shenqingxm.xm_id = think_shenqing.xm_id and think_shenqing.bh = think_lingxing_sbjj.bh and states ='7' and think_shenqing.bh = allca_bh and allca_name='"+name+"' ";
		
		if(js_id.contains(",20,"))
		{
			sql = "select count(*) from think_shenqing,think_shengqinglc,think_shenqingbz,think_shenqingxm,think_lingxing_sbjj,think_allcateshenqing " +
			"where think_shenqing.lc_id = think_shengqinglc.lc_id and think_shenqing.xm_id='4' and last_lc = '计财处审核通过'  and think_shenqingbz.bz_id = think_shengqinglc.bz_id and think_shenqingxm.xm_id = think_shenqing.xm_id and think_shenqing.bh = think_lingxing_sbjj.bh and states ='7' and think_shenqing.bh = allca_bh  ";
		}
		
		return getSingleVal(sql);
	}

}
